import 'package:cateapp/base_quest.dart';
import 'package:cateapp/base_url.dart';
import 'package:cateapp/generated/json/base/doctor_team_list_entity.dart';
import 'package:dio/dio.dart';

import 'generated/json/base/doc_home_list_news_entity.dart';
import 'generated/json/base/json_convert_content.dart';
import 'generated/json/base/juejin_list_entity.dart';

class FootRequest {

   static Future getFoodListRequest() async {
    var dio = Dio();
    dio.options =  BaseOptions(headers: {"authorization":"bearer 378f9113-b957-40f7-9fb1-ace179d7d9cc"});
    Response response = await dio.get('https://beta-ynjtysapp.yiboshi.com/v1/fds-app/message-info/index/5');

    DocHomeListNewsEntity model = JsonConvert.fromJsonAsT(response.data);
    for (var newModel in model.data.recommend) {
        print(newModel.title);
        print(newModel.unitName);
    }
   return response.data;
//    return YYHttpRequest.request(YYApiUrl.foodListUrl,headers: {"appName":"cateapp"},params: {"user_id":"3139860942038334","cursor":"0"});
  }

   static Future getHomeListNewsRequestBlock(Map<String, dynamic> params,
       Function(DocHomeListNewsEntity t) onSuccess,
       {Function(String error) onError, Map<String, dynamic> headers = const {}
       }) async {
     await YYHttpRequest.request(YYApiUrl.homeListNews, (data) {
//       print(data);
       DocHomeListNewsEntity result = JsonConvert.fromJsonAsT(data);
       onSuccess(result);
     }, (error) {
       onError(error);
     }, headers:headers,params: params,method: YYHttpRequestMethod.Get,
     );
   }

   static Future getDoctorTeamListRequestBlock(Map<String, dynamic> params,
       Function(DoctorTeamListEntity t) onSuccess,
       {Function(String error) onError, Map<String, dynamic> headers = const {}
       }) async {
     await YYHttpRequest.request(YYApiUrl.homeDocTeamList, (data) {
//       print(data);
       DoctorTeamListEntity result = JsonConvert.fromJsonAsT(data);
       onSuccess(result);
     }, (error) {
       onError(error);
     }, headers:headers,params: params,method: YYHttpRequestMethod.Get,
     );
   }

  static Future getFoodListRequestBlock(Map<String, dynamic> params,
      Function(JuejinListEntity t) onSuccess,
      {Function(String error) onError, Map<String, dynamic> headers = const {}
      }) async {
    await YYHttpRequest.request(YYApiUrl.foodListUrl, (data) {
      print(data);
      JuejinListEntity result = JsonConvert.fromJsonAsT(data);
      onSuccess(result);
    }, (error) {
      onError(error);
    }, headers:headers,params: params,method: YYHttpRequestMethod.Get,
    );
  }
}
